/*
 * ========================================================================
 *
 *       Filename:  card.cpp
 *
 *    Description:  This is the implementation of the FlashCard and
 *                  StudyCard classes.
 *
 *        Version:  1.0
 *        Created:  05/10/2010 11:18:37 AM
 *       Revision:  none
 *       Compiler:  g++
 *
 *         Author:  Alex Avance (aa), aravance@gmail.com
 *        Company:  independent
 *
 * ========================================================================
 *
 * Copyright (C) 2010 Alex Avance
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-
 * 1307, USA.
 *
 * ========================================================================
 */
#include "card.h"

/**************************************************************************
Class Name: FlashCard
Method Name: operators
Description: comparison operators
**************************************************************************/
bool operator== ( const FlashCard &one, const FlashCard &two )
{
  return ( one.m_Front == two.m_Front && one.m_Back == two.m_Back );
}

bool operator!= ( const FlashCard &one, const FlashCard &two )
{
  return ( one.m_Front != two.m_Front || one.m_Back != two.m_Back );
}

bool operator< ( const FlashCard &one, const FlashCard &two )
{
  return ( one.m_Front < two.m_Front ||
           ( one.m_Front == two.m_Front && one.m_Back < two.m_Back ) );
}

bool operator<= ( const FlashCard &one, const FlashCard &two )
{
  return !( one > two );
}

bool operator> ( const FlashCard &one, const FlashCard &two )
{
  return ( one.m_Front > two.m_Front ||
           ( one.m_Front == two.m_Front && one.m_Back > two.m_Back ) );
}

bool operator>= ( const FlashCard &one, const FlashCard &two )
{
  return !( one < two );
}

/**************************************************************************
Class Name: FlashCard
Method Name: FlashCard
Description: constructor
**************************************************************************/
FlashCard::FlashCard ()
{} // ----- end of method FlashCard::FlashCard (constructor) -----

/**************************************************************************
  Class Name: FlashCard
  Method Name: FlashCard
Description: copy constructor
 **************************************************************************/
FlashCard::FlashCard ( const FlashCard &other )
  : m_Front( other.m_Front ), m_Back( other.m_Back )
{} // ----- end of method FlashCard::FlashCard (copy constructor) -----

/**************************************************************************
Class Name: FlashCard
Method Name: FlashCard
Description: constructor
**************************************************************************/
FlashCard::FlashCard ( const wxString &front, const wxString &back)
  : m_Front( front ), m_Back( back )
{} // ----- end of method FlashCard::FlashCard (constructor) -----

/**************************************************************************
Class Name: FlashCard
Method Name: operator=
Description: assignment operator
**************************************************************************/
const FlashCard& FlashCard::operator= ( const FlashCard &other )
{
  if ( this != &other )
  {
    m_Front= other.m_Front;
    m_Back= other.m_Back;
  }
  return *this;
} // ----- end of method FlashCard::operator= (assignment operator) -----

/**************************************************************************
Class: FlashCard
Method: Front Accessors
Description: Access the front element in various ways.
**************************************************************************/
FlashCard::InfoT& FlashCard::Front ()
{ return m_Front; } // ----- end of method FlashCard::Front -----
const FlashCard::InfoT& FlashCard::Front () const
{ return m_Front; } // ----- end of method FlashCard::Front -----
const FlashCard::InfoT& FlashCard::GetFront () const
{ return m_Front; } // ----- end of method FlashCard::GetFront -----

/**************************************************************************
Class: FlashCard
Method: Back Accessors
Description: Access the back element in various ways.
**************************************************************************/
FlashCard::InfoT& FlashCard::Back ()
{ return m_Back; } // ----- end of method FlashCard::Back -----
const FlashCard::InfoT& FlashCard::Back () const
{ return m_Back; } // ----- end of method FlashCard::Back -----
const FlashCard::InfoT& FlashCard::GetBack () const
{ return m_Back; } // ----- end of method FlashCard::GetBack -----

/**************************************************************************
Class: FlashCard
Method: Element Modifiers
Description: This is used to set  the corresponding element
**************************************************************************/
const FlashCard::InfoT& FlashCard::SetFront ( const InfoT &front )
{ return ( m_Front= front ); } // ----- end of method FlashCard::SetFront -----
const FlashCard::InfoT& FlashCard::SetBack ( const InfoT &back )
{ return ( m_Back= back ); } // ----- end of method FlashCard::SetBack -----

/**************************************************************************
Class Name: StudyCard
Method Name: StudyCard
Description: constructor
**************************************************************************/
StudyCard::StudyCard ()
  : FlashCard(), StatInfo()
{} // ----- end of method StudyCard::StudyCard (constructor) -----

/**************************************************************************
Class Name: StudyCard
Method Name: StudyCard
Description: copy constructor
**************************************************************************/
StudyCard::StudyCard ( const StudyCard &other )
  : FlashCard( other ), StatInfo( other )
{} // ----- end of method StudyCard::StudyCard (copy constructor) -----

/**************************************************************************
Class Name: StudyCard
Method Name: StudyCard
Description: copy constructor
**************************************************************************/
StudyCard::StudyCard ( const FlashCard &card, const StatT &right, const StatT &wrong )
  : FlashCard( card ), StatInfo( right, wrong )
{} // ----- end of method StudyCard::StudyCard (copy constructor) -----

/**************************************************************************
Class Name: StudyCard
Method Name: StudyCard
Description: constructor
**************************************************************************/
StudyCard::StudyCard ( const InfoT &front, const InfoT &back,
                       const StatT &right, const StatT &wrong )
  : FlashCard( front, back ), StatInfo( right, wrong )
{} // ----- end of method StudyCard::StudyCard (constructor) -----

/**************************************************************************
Class Name: StudyCard
Method Name: operator=
Description: assignment operator
**************************************************************************/
StudyCard& StudyCard::operator= ( const FlashCard &card )
{
  if ( this != &card )
  {
    m_Back= card.GetFront();
    m_Front= card.GetBack();
    m_Right= 0;
    m_Wrong= 0;
  }
  return *this;
} // ----- end of method StudyCard::operator= (assignment operator) -----

/**************************************************************************
Class Name: StudyCard
Method Name: operator=
Description: assignment operator
**************************************************************************/
StudyCard& StudyCard::operator= ( const StudyCard &other )
{
  if ( this != &other )
  {
    m_Back= other.m_Back;
    m_Front= other.m_Front;
    m_Right= other.Right();
    m_Wrong= other.Wrong();
  }
  return *this;
} // ----- end of method StudyCard::operator= (assignment operator) -----

